//package com.zut.netty;
//
//import io.netty.bootstrap.Bootstrap;
//import io.netty.channel.ChannelFuture;
//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.ChannelOption;
//import io.netty.channel.EventLoopGroup;
//import io.netty.channel.nio.NioEventLoopGroup;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.channel.socket.nio.NioSocketChannel;
//import org.springframework.stereotype.Component;
//
//@Component
//public class NettyClient {
//
//    private final static String IP="192.168.88.140";
//
//    private final static int JudgePort=2586;
//
//    static {
//        //配置客户端的线程组，客户端只有一个线程组
//        EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
//        try {
//            Bootstrap bootstrap = new Bootstrap();
//            bootstrap.group(eventLoopGroup).channel(NioSocketChannel.class)
//                    .option(ChannelOption.TCP_NODELAY, true)
//                    .handler(new ChannelInitializer<SocketChannel>() {
//                        @Override
//                        protected void initChannel(SocketChannel socketChannel) throws Exception {
//                            //放入自己的业务Handler
//                            socketChannel.pipeline().addLast(new TCPClientHandler());
//                        }
//                    });
//            //发起异步连接操作，同步阻等待结果
//            ChannelFuture channelFuture = bootstrap.connect(IP, JudgePort).sync();
//            //等待客户端链路关闭
//            channelFuture.channel().closeFuture().sync();
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        } finally {
//            //释放NIO线程组
//            eventLoopGroup.shutdownGracefully();
//        }
//    }
//
//
//
//
//}
